package com.ruoyi.sms.enums;

import com.ruoyi.sms.strategy.impl.AliSmsStrategy;

/**
 * 发送短信服务商枚举
 */
public enum SendProvider {

    ALI_SMS(1, AliSmsStrategy.class.getSimpleName());

    private Integer code;

    private String beanName;

    SendProvider(Integer code, String beanName) {
        this.code = code;
        this.beanName = beanName;
    }

    /**
     * 根据code获取对应的枚举对象
     */
    public static SendProvider getEnum(Integer code) {
        SendProvider[] values = SendProvider.values();
        if (null != code && values.length > 0) {
            for (SendProvider value : values) {
                if (value.code.equals(code)) {
                    return value;
                }
            }
        }
        return null;
    }

    /**
     * 该code在枚举列表code属性是否存在
     */
    public static boolean containsCode(Integer code) {
        SendProvider anEnum = getEnum(code);
        return anEnum != null;
    }

    /**
     * 判断code与枚举中的code是否相同
     */
    public static boolean equals(Integer code, SendProvider calendarSourceEnum) {
        return calendarSourceEnum.code.equals(code);
    }


    public Integer getCode() {
        return code;
    }

    public String getBeanName() {
        return beanName;
    }
}
